import React from 'react';
import { Flex, WingBlank, WhiteSpace, List, Card, Progress } from 'antd-mobile';
import { SCALE_DIA_VALUE } from 'const';

const { Item, Item: { Brief } } = List;
Array.prototype.unique2 = function(){
 this.sort(); //先排序
 var res = [this[0]];
 for(var i = 1; i < this.length; i++){
  if(this[i] !== res[res.length - 1]){
   res.push(this[i]);
  }
 }
 return res;
}
export default function ScaleReport(props) {
    window.scrollTo(0, 0);
    let normal = [], tongues = [], main = [];
    if (props.PatientValue.patientValue1 && props.PatientValue.patientValue1.indexOf("|") == -1) {
      const Dia = props.PatientValue.patientValue1.split(',');
      for (var i = Dia.length - 1; i >= 0; i--) {
         for (var j in SCALE_DIA_VALUE) {
          if (SCALE_DIA_VALUE[j].id == Dia[i]) {
            main.push(SCALE_DIA_VALUE[j]);
          }
        }
      }
     for (var z = main.length - 1; z >= 0; z--) {
        if(main[z].id>=202 && main[z].id<=219){
          tongues.push(main[z].title);
        }else{
          normal.push(main[z].title);
        }
      }
  }
  return (
       <WingBlank size="md">
      <List wrap>
        <Item>
            <Flex justify="center">糖尿病辅助辨证报告</Flex>
            <WhiteSpace/>
            <Flex justify="end">
                <div style={{fontSize: '0.25rem'}}>
                    {props.createTime}
                </div>
            </Flex>
        </Item>
        <Item>
          一般症状
            <div style={{whiteSpace: "normal", textIndent: "2em"}}>{normal.unique2().join("; ")}</div>
          <WhiteSpace size="lg" />
        </Item>
        <Item>
          舌脉症状
            <div style={{whiteSpace: "normal", textIndent: "2em"}}>{tongues.join("; ")}</div>
          <WhiteSpace size="lg" />
        </Item>
        <Item>
          辨证分型
            <div style={{whiteSpace: "normal", textIndent: "2em"}}>{props.report1}</div>
          <WhiteSpace size="lg" />
        </Item>
        <Item>
          医生建议
          <WhiteSpace size="lg" />
        </Item>
      </List>
    </WingBlank>
  );
}